<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">所有二维码</a></li>
    </ul>
    <div class="well form-inline margin-top-20">
        关键字:
        <input type="text" class="form-control sertext" name="keyword" style="width: 200px;"
               value="" placeholder="请输入关键字...">
        <a class="btn btn-danger" href="{:url('code/codewatch')}">返回</a>
    </div>
    <script>
        //然后检测显示
        $('.sertext').bind(' input propertychange ',function(){
            var lenss = $.trim($('.sertext').val());
            if(lenss != ''){
                var ser = $('.sertext').val();
                $.ajax({
                    url:'/mainiu/code/ser',
                    type:"post",
                    data:{
                        text:ser
                    },
                    success:function(data){
                        var ress= $.parseJSON(data);
                        if(ress==''){
                            $('.ads').hide();
                            $('.text1').show();
                            return false;
                        }else {
                            $('.text1').hide();
                            $('.ads').show();
                            $.each(ress, function (n, value) {
                                $('.bounceInLeft').remove();
                                $('.ads').append(
                                    "<tr class='animated bounceInLeft d"+value.id+"'>"+
                                    "<td><b>"+value.id+"</b></td>"+
                                    "<td>"+value.des+"</td>"+
                                    "<td>"+value.url+"</td>"+
                                    "<td>"+
                                    "<a href='"+value.thumb+"' target='_blank'><img style='width: 10em' src='"+value.thumb+"' alt='二维码'></a>"+
                                    "</td>"+
                                    "<td>"+value.time+"</td>"+
                                    "<td><a class=\"dd\" style='cursor: pointer' onclick='dd(this)' id='"+value.id+"'>删除</a></td>"+
                                    "</tr>"
                                );
                            });
                            $('.mpp3')[0].play()
                        }
                    },
                    error:function(e){
                        alert('加载失败！')
                    }
                });
            }
        } );
    </script>
    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered table-list">
            <thead class="ads">
            <tr>
                <th width="50">ID</th>
                <th>二维码描述</th>
                <th>二维码地址</th>
                <th width="160">二维码图片</th>
                <th width="130">添加时间</th>
                <th width="90">操作</th>
            </tr>
            </thead>
            <p class="text1" style="color: red;font-size: 20px;display: none;">没有找到任何数据</p>
        </table>
        <audio class="mpp3" controls="controls">
            <source src="__TMPL__/public/623.mp3"/>
        </audio>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    window.onload = function(){
        $('.mpp3').hide();
        $.ajax({
            url:'/mainiu/code/returncode',
            type:"post",
            data:{},
            success:function(data){
                var ress= $.parseJSON(data);
                if(ress==''){
                    $('.ads').hide();
                    $('.text1').show();
                    return false;
                }else {
                    $('.text1').hide();
                    $('.ads').show();
                    $.each(ress, function (n, value) {
                        $('.ads').append(
                            "<tr class='animated bounceInLeft d"+value.id+"'>"+
                            "<td><b>"+value.id+"</b></td>"+
                            "<td>"+value.des+"</td>"+
                            "<td>"+value.url+"</td>"+
                            "<td>"+
                            "<a href='"+value.thumb+"' target='_blank'><img style='width: 10em' src='"+value.thumb+"' alt='二维码'></a>"+
                            "</td>"+
                            "<td>"+value.time+"</td>"+
                            "<td><a class=\"dd\" style='cursor: pointer' onclick='dd(this)' id='"+value.id+"'>删除</a></td>"+
                            "</tr>"
                        );
                    });
                    $('.mpp3')[0].play()
                }
            },
            error:function(e){
                alert('加载失败！')
            }
        });
    };
    function dd(obj) {
        $.ajax({
            url:'/mainiu/code/del',
            type:"post",
            data:{
                id:obj.id
            },
            success:function(data){
                var ress= $.parseJSON(data);
                if(ress.sta==1){
                    alert('删除成功')
                }
                $('.d'+ress.id).delay(500).hide(300);;
            },
            error:function(e){
                alert('删除失败！')
            }
        });
    }
</script>
</body>
</html>